package com.mark.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.mark.database.Mark1;
import com.mark.database.Mark2;
import com.mark.toolImpl.DelMarkImpl;

import net.sf.json.JSONObject;

public class DelMarkServlet extends HttpServlet {

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		HttpSession session = request.getSession();
		JSONObject message=new JSONObject();
		if(session.getAttribute("uId")!=null){
			int Uid=Integer.valueOf(String.valueOf(session.getAttribute("uId")));
			int jobid=Integer.valueOf(request.getParameter("jobId"));
			String paytype=request.getParameter("paytype");
			DelMarkImpl del=new DelMarkImpl();
			if(paytype.equals("日结")){
				
				Mark1 m1=new Mark1();
				m1.setJobId(jobid);
				m1.setUid(Uid);
				if(del.delMark1(m1)){
					message.put("message", "删除成功！");
				}
				else{
					message.put("message", "删除失败！");
				}
			}
			else{
				Mark2 m2=new Mark2();
				m2.setJobId(jobid);
				m2.setUid(Uid);
				if(del.delMark2(m2)){
					message.put("message", "删除成功！");
				}
				else{
					message.put("message", "删除失败！");
				}
			}
		}
		else{
			message.put("message", "���ȵ�¼");
		}
		response.getWriter().print(message);  
	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doGet(request, response);
	}

}
